<!DOCTYPE html>
<html ng-app="" >
	<head>
		<meta charset="UTF-8">
		<title>循环</title>
	</head>
	<body>
		<!-- 嵌在HTML中 -->
		<nav id="nav" ng-init="navList=[{name:'首页', link:'javascript:;'},{name:'关于我们', link:'javascript:;'}]">
			<ul>
				<li ng-repeat="nav in navList">
					{{nav.name}}
				</li>
			</ul>
		</nav>
		
		<!-- 全用js设置 -->
		<nav id="nav2">
			<ul>
				<li></li>
			</ul>
		</nav>
		
		<script>
			var data = "navList=[{name:'首页', link:'javascript:;'},{name:'关于我们', link:'javascript:;'}]";
			var nav = document.getElementById("nav2");
			var li = nav.getElementsByTagName("li")[0];
			nav.setAttribute("ng-init", data);
			li.setAttribute("ng-repeat", "nav in navList");
			li.innerHTML = "{{nav.name}}";
			
			var script = document.createElement('script');
			script.setAttribute('src', "http://cdn.gbtags.com/angular.js/1.2.20/angular.min.js");
			var jsList = document.getElementsByTagName('script');
			// 在节点第首位追加新节点，但会存在jQuery未定义的问题，可能是密闭空间内无法再次导入新定义的
			document.body.insertBefore(script, jsList[0]);
		</script>
	</body>
</html>
